package com.main.hotel.service.impl;

import com.main.hotel.entity.Bill;
import com.main.hotel.repository.BillRepository;
import com.main.hotel.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class BillServiceImpl implements BillService {

    @Autowired
    private BillRepository billRepository;

    @Override
    public Long findTotalCost() {
        Long money;
        money = billRepository.findTotalCost();
        return money;
    }

    @Override
    public Page<Bill> findAll(int page, int pageSize) {
        Pageable pageable= PageRequest.of(page,pageSize);
        return billRepository.findAll(pageable);
    }

    @Override
    public int addBill(Bill bill) {
        billRepository.save(bill);
        return 1;
    }

}
